package com.scs.application.modules.upms.controller;

import com.scs.application.core.model.CommonResult;
import com.scs.application.core.mvc.controller.BaseController;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.core.utils.WebUtils;
import com.scs.application.modules.upms.service.LogoutService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/upms")
public class LogoutController extends BaseController {

    private final LogoutService logoutService;


    @DeleteMapping("/logout")
    public CommonResult logout(String isUnBindVx) {
        String token = WebUtils.getAccessToken();

        if (StringUtils.isBlank(token)) {
            return CommonResult.ok("登出成功");
        }
        logoutService.logout(token,"1".equals(isUnBindVx));
        return CommonResult.ok("登出成功");
    }

}
